<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>EHS群组文章-EHS中国-</title>
    <link href="__TMPL__/style/group-style.css" rel="stylesheet" type="text/css" media="screen" />
    <script type="text/javascript" src="__ROOT__/Public/Js/jquery-1.5.0.min.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/Js/core.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/Js/ehs.js"></script>
<!--    <script language="javascript" type="text/javascript" src="__TMPL__/js/ajax.js"></script>
    <script language="javascript" type="text/javascript" src="__TMPL__/js/web.js"></script>-->
  </head>
  <body>
    <layout name="Public:header0523" cache="1" />
    <div class="main">
    <layout name="Public:group-member-base" cache="0" />
    <div class="content" style="height:auto;overflow:hidden" >
	
      <div class="content_left" style="width:687px;">
        <layout name="Public:circle-group-header" cache="0" />
        <div class="content_right_border" style="line-height:30px; padding-left:20px;width: 660px">
          <form id="frm" method="post" action="__URL__/save/">
            <div><strong>所属群组：{$cname}</strong></div>
            <div style="float:left;">标题：
              <input id="txtTitle" onkeydown="CharCountCheck('txtTitle','tTips',50)" onkeyup="CharCountCheck('txtTitle','tTips',50)" name="title" onblur="BCharCountCheck('txtTitle',50)" type="text" value="{$item.title}" style="width:350px;"/> 
            <span style="color:#999; padding-left:10px;" id='tTips'>限制50字节</span></div>
            <div style="float:right; margin-right:20px; margin-bottom:10px; height:30px;">文章类型：<select name="type"><option value="1">原创</option><option value="2">转载</option><option value="3">问题</option></select></div>
            <textarea id="txtContent" name="content" cols="100" rows="8" style="width:640px;height:400px;margin:0 auto;padding:0">{$item.content}</textarea>
            <br />
			<span id="cTips"></span>
			<if condition='$aid eq 0'>
			<div style="height:16px;line-height:16px;margin-bottom:10px;">
			<input name="toDiary" id="toDiary" type="checkbox" value="1" onclick="showType();" />同时发布到我的博文
			&nbsp;&nbsp;<span id='dtype' style="display:none">博文分类<select name="dtid">
			  <option value="0">默认分类</option>
			  <volist name='dtype' id='itm'>
			    <option value="{$itm.dtid}">{$itm.name}</option>
			  </volist>
			</select></span></div>
			</if>
            <script charset="utf-8" src="__TMPL__/js/editor/kindeditor.js"></script>
            <input name="button" id="subbut" type="button" onclick="save()" value="发表" />
            <input type="reset" value="清除"/>
            <input type="button" onclick="javascript:window.history.go(-1)"value="返回"/>
            <input name="cyid" value="{$cyid}" type="hidden"/>
			<input name="aid" value="{$aid}" type="hidden"/>
            <input name="uid" value="{$uid}" type="hidden"/>
			<input name="diary_id" value="{$item.diary_id}" type="hidden"/>
          </form>
        </div>
      </div>

      <div class="content_right">
        <layout name="Public:group-right" cache="0" />
     </div>
     
	  <div class="clear"></div>
      
	  </div>  <!--end content-->
	    
      <div class="footer" style="clear:both"><layout name="Public:footer" cache="0" /></div>
      </div>

    <script>
      KE.show({
        id : 'txtContent',
		resizeMode:1,
        items:['justifyleft', 'justifycenter', 'justifyright',
          'justifyfull','|','paste', 'wordpaste', '|',
          'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
          'italic', 'underline','|', 'image',
          'flash', 'media', 'table', 'emoticons']
      });
	  
	  //检查字符长度
	  CharCountCheck('txtTitle','tTips',50);
	  
      function save(){
        var title = $("#txtTitle").val();
		var content=$("#txtContent").val();
		
        if (title == "") {
          alert("请输入标题");
          return ;
        }
        if (content == "") {
          alert("文章内容不能为空");
          return ;
        }
        //var tlen = title.replace(/[^\x00-\xff]/g, "**").length;
		var tlen=CharCountCheck('txtTitle','tTips',50);
		var clen =content.replace(/[^\x00-\xff]/g, "**").length;
        var max = 50;
        if (!tlen) {
          alert("你输入的标题超过30字节，请重新输入");
          return false;
        }else if(clen<30){
		  alert("发布内容过短");
		  return false;
		}
		
		$('#subbut').attr('disabled','disabled');
		$('#subbut').val('提交中....');
        ajax.sendForm("frm",function(data){
		  alert(data.info);
		  if(data.status=='0'){
		    $('#subbut').attr('disabled','');
		    $('#subbut').val('提交');
		  }else{
		    if(data.data!='')location.href=data.data; 
		  }		  
		});
      }
	  
	  function showType(){
		if($("#toDiary").attr('checked')){   
	      $('#dtype').css('display','inline');
		}else{
		  $('#dtype').css('display','none');
		}
	  }
    </script>
  </body>
</html>
